package ibmetp.mis.common;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class JdbcUtil {

	public static String formatDate(Date d)
	{
		if(d==null)
		{
			return "";
		}
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		return sdf.format(d);
	}
	public static Date string2Date(String d)
	{
		if(d==null || d.trim().length()==0)
		{
			return null;
		}
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		try 
		{
			return sdf.parse(d);
		}
		catch (ParseException e)
		{
			e.printStackTrace();
			return null;
		}
	}
	
	public static String array2String(String[] strs)
	{
		if(strs==null)
		{
			return "";
		}
		String result="";
		for (String string : strs) {
			
			result+=string+",";
		}
		return result.substring(0,result.length()-1);
	}
	
	public static String[] string2Array(String str)
	{
		if(str==null)
		{
			return null;
		}
		return str.split(",");
	}
}
